import sqlexecx as db
from config import MYSQL

if __name__ == '__main__':
    # db.init(**MYSQL)
    db.init('test.db', driver='sqlite3', show_sql=True, debug=True)

    for row in db.select('select id, name, age from person'):
        print(row)
    print(db.select_page('select id, name, age from person where name =?', 2, 2, '李四'))
    print(db.query_page('select id, name, age from person where name =?', 1, 2, '李四'))
    print(db.select_page('select id, name, age from person where name =:name', 2, 2, name='李四'))
    print(db.query_page('select id, name, age from person where name =:name', 1, 2, name='zhangsan'))

    print(db.page(1, 2).query('select id, name, age from person where name =:name', name='李四'))
    print(db.page(1, 2).select('select id, name, age from person where name =:name', name='李四'))
    print(db.page(1, 2).do_query('select id, name, age from person where name =?', '李四'))
    print(db.page(1, 2).do_select('select id, name, age from person where name =?', '李四'))
